<?php
	/**
	* Save user in Manage user explorer
	* @author trungdt
	* @since Apr, 2012
	*/

	if (!defined('EXPONENT')) exit('');
	if (exponent_users_isAdmin() || exponent_permissions_check(array("administrate"),$loc))
	{
		$fuser = null;

		if (isset($_POST['id'])) {
			$fuser = $db->selectObject('filemanagermodule_users','id='.intval($_POST['id']));
		} 

		// update
		$fuser->homedir=trim($_POST['homedir']);
		$fuser->show_hidden = intval($_POST['show_hidden']);
		$fuser->pattern_hidden=$_POST['pattern_hidden'];
		$fuser->permissions = intval($_POST['permissions']);
		$fuser->active = intval($_POST['active']);
		$fuser->user_id =intval($_POST['user_id']);
		
		// check homedir
		if ($fuser->homedir == "")
		{
			$fuser->homedir ="/files/";
		}
		//
		if (isset($fuser->id)) {
			$db->updateObject($fuser,'filemanagermodule_users');
		} else {
			$db->insertObject($fuser,'filemanagermodule_users');
		}
		exponent_flow_redirect();
	}
	else {
		echo SITE_404_HTML;
	}

?>